package com.mirror.llk;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.mirror.llk.logic.ThemeLogic;
import com.mirror.llk.view.ThemeDownloadView;
import com.mirror.utils.AnimationUtil;
import com.mirror.utils.base.Page;
import com.mirror.utils.view.CustomListView.OnRefreshLoadListener;

public class ThemeDownloadActivity extends Activity {

	public ThemeDownloadView downloadView;

	private ThemeLogic logic = new ThemeLogic();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		downloadView = new ThemeDownloadView(this);
		setContentView(downloadView);
		init();
		load();
	}

	private void init() {
		downloadView.lvOfficial.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> adapterView, View arg1, int index, long arg3) {
				// TODO 转至详情页
			}
		});
		downloadView.lvOfficial.setOnRefreshLoadListener(new OnRefreshLoadListener() {

			@Override
			public void onRefresh(Page page) {
				downloadView.lvOfficial.setLayoutAnimation(AnimationUtil.getAnimation());
				logic.queryThemeOfficialPage(downloadView, page);
			}

			@Override
			public void onLoadMore(Page page) {
				logic.queryThemeOfficialPage(downloadView, page);
			}

		});

		downloadView.lvPrivate.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> adapterView, View arg1, int index, long arg3) {
				// TODO 转至详情页
			}
		});
		downloadView.lvPrivate.setOnRefreshLoadListener(new OnRefreshLoadListener() {

			@Override
			public void onRefresh(Page page) {
				downloadView.lvPrivate.setLayoutAnimation(AnimationUtil.getAnimation());
				logic.queryThemePrivatePage(downloadView, page);
			}

			@Override
			public void onLoadMore(Page page) {
				logic.queryThemePrivatePage(downloadView, page);
			}

		});
	}

	private void load() {
		downloadView.lvOfficial.load();
		downloadView.lvPrivate.load();
	}
}
